from django.contrib.auth.hashers import make_password, check_password
from django.contrib.auth.models import AbstractUser, Group, Permission
from django.db import models


class UserInfo(AbstractUser):
    """
    用户表
    """
    id = models.AutoField(primary_key=True)
    Account = models.CharField(max_length=50, help_text="账号")
    password = models.CharField(max_length=255,help_text="密码")
    role = models.IntegerField(help_text="权限")

    class Meta:
        verbose_name = "用户信息"
        verbose_name_plural = "用户信息"
        db_table = 'userinfo'

    def check_Password(self, password):
        # 使用 Django 的 check_password 方法来验证密码
        return check_password(password, self.password)

    def set_Password(self, password):
        return make_password(password)

